import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 杨已萱
 * Date: 2023-04-23
 * Time: 20:36
 */
public class Game {
    public static final String[] colors ={"♠","♣","♥","♦"};

    public List<EveryPoker> CreatPoker(){
        List<EveryPoker> pokers = new ArrayList<>();//List只是借口要用实现这个借口的ArrayList
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                EveryPoker poker = new EveryPoker(colors[i],j);//生成之后因该将每一个扑克添加到Poker牌盒中
                pokers.add(poker);//写在最里层循环里，每生成一张都要添加
            }
        }
        return pokers;
    }
    public void MassUp(List<EveryPoker> pokers){//传牌当参数！！！洗和牌产生联系
        for (int i = pokers.size()-1 ; i > 0 ; i--) {
            Random random = new Random();//Random 类的random方法
            int index = random.nextInt(i);//随机生成[0,i)之间的值
//            System.out.println(index);
            swap(pokers,i,index);//i就是遍历倒着往前的，每张牌都换；index是随机下标的牌
                                 //不能只有i,index参数要将这俩与扑克联系起来！
        }
    }
    public void swap(List<EveryPoker> pokers,int i,int j){
//        String temp = null;//不行pokers.get提供的是一个泛型必须用EveryPoker接受
        EveryPoker temp = pokers.get(i);
//        pokers.set(j,pokers.get(i));//不能这样写得画图！i下标给temp了，i没有了
        pokers.set(i,pokers.get(j));
        pokers.set(j,temp);
    }
    public List<List<EveryPoker>> DrawCard(List<EveryPoker> pokers){//错吧List<EveryPoker>当返回类型了
        List<List<EveryPoker>> person = new ArrayList<>();//2维数组：使person123产生联系
        List<EveryPoker> person1 = new ArrayList<>();
        List<EveryPoker> person2 = new ArrayList<>();
        List<EveryPoker> person3 = new ArrayList<>();//忘记add了！！！使person123产生联系
        person.add(person1);
        person.add(person2);
        person.add(person3);

        //轮数
        for (int i = 0; i < 3; i++) {
            //人数
            for (int j = 0; j < 3 ; j++) { //也可以控制二维数组person的下标
//                pokers.get()//不是get0下标是remove0 下标
                EveryPoker removepoker = pokers.remove(0);
                person.get(j).add(removepoker);//取下标一定记得是get()
            }
        }
        return person;
    }

}
